/*********************************************************************************/
/*                                                                               */
/*      ABZ Driver                                                               */
/*                                                                               */
/*      Last updated by:   CBS                                                   */
/*      Last update date:  13/02/05                                              */
/*      Revision:          0                                                     */
/*      Copyright:         DENSO                                                 */
/*                                                                               */
/*********************************************************************************/
#ifndef ABZ_CFG_H_
#define ABZ_CFG_H_

/*********************************************************************************/
/*  include files                                                                */
/*********************************************************************************/
#include "Std_Types.h"

/*********************************************************************************/
/*  defines / data types / structs / unions / macros                             */
/*********************************************************************************/

/****************************************/
/*  optional API configurations         */
/****************************************/
#define ABZ_DE_INIT_API            STD_ON

#define ABZ_SIGNAL_MEASUREMENT_API STD_ON

#define ABZ_GET_ANGLE_POSITION_API STD_ON

#define ABZ_GET_ROTATION_SPEED_API STD_ON

#define ABZ_GET_VERSION_INFO_API   STD_ON
/****************************************/

#define ABZ_SYSTEM_CLOCK ((U4)30000000)  /* unit: Hz */

#define ABZ_CLOCK_SCALER ((U4)0xf9)      /* 250 */

#define ABZ_INTERNAL_PRESCALER ((U4)0x3) /* 4 */

#define PI (3.14)

typedef enum{ 
    ABZ_CHANNEL_A = (U1)6,   /* Since channel 0~5 has been used, we start from 6 */
    ABZ_CHANNEL_B = (U1)7,
    ABZ_CHANNEL_Z = (U1)8,
    
    ABZ_NUMBER_OF_CHANNELS = (U1)3
}Abz_NamedChannelsType;

typedef enum{
    ABZ_MODE_SIGNAL_EDGE_DETECT,
    ABZ_MODE_SIGNAL_MEASUREMENT,
    ABZ_MODE_EDGE_COUNTER
}Abz_MeasurementModeType;

typedef enum{
    ABZ_RISING_EDGE,
    ABZ_FALLING_EDGE,
    ABZ_BOTH_EDGES
}Abz_ActivationType;

typedef enum{
    ABZ_LOW_TIME,
    ABZ_HIGH_TIME,
    ABZ_ACTIVE_TIME,
    ABZ_PERIOD_TIME
}Abz_SignalMeasurementPropertyType;

typedef struct{
    Abz_SignalMeasurementPropertyType AbzSignalMeasurementProperty;
}Abz_SignalMeasurementConfigType;

typedef Abz_ActivationType Abz_DefaultStartEdgeType;

typedef struct {                 /************************************************/
    U4    CADR:32;               /* CADR                                         */
    U4    CBDR:32;               /* CBDR                                         */
    U4    counter:32;            /* Counter                                      */
    U4    freezeEnable:1;        /* Enable freezing channel                      */
    U4    outputDisable:1;       /* Disable output                               */
    U4    outputDisableSelect:2; /* Select which bus disables the bus            */
    U4    prescaler:2;           /* Prescaler Value                              */
    U4    usePrescaler:1;        /* Enable prescaler                             */
    U4    useDma:1;              /* Enable DMA                                   */
    U4    reserved_2:1;          /*                                              */
    U4    inputFilter:4;         /* Input filter                                 */
    U4    filterClockSelect:1;   /* Input filter clock source                    */
    U4    flagEnable:1;          /* Enable interrupts/flags on this channel      */
    U4    reserved_3:3;          /*                                              */
    U4    forceMatchA:1;         /* Trigger a match on channel A                 */
    U4    forceMatchB:1;         /* Trigger a match on channel B                 */
    U4    reserved_4:1;          /*                                              */
    U4    busSelect:2;           /* Use the internal counter                     */
    U4    edgeSelect:1;          /* What edges to flag on?                       */
    U4    edgePolarity:1;        /* Polarity of the channel                      */
    U4    mode:7;                /* EMIOS mode                                   */
}Abz_ChannelRegisterType;        /************************************************/

typedef struct{
    U1 AbzChannelId;
    Abz_DefaultStartEdgeType AbzDefaultStartEdge;
    Abz_MeasurementModeType AbzMeasurementMode;
    Abz_SignalMeasurementConfigType Abz_SignalMeasurementConfig;
    Abz_ChannelRegisterType Abz_ChannelRegister;
}Abz_ChannelConfigType;

typedef struct
{
    Abz_ChannelConfigType AbzChannels[ABZ_NUMBER_OF_CHANNELS];
}Abz_ConfigType; 

/*********************************************************************************/
/*  variables                                                                    */
/*********************************************************************************/

/*********************************************************************************/
/*  constants                                                                    */
/*********************************************************************************/

/*********************************************************************************/
/*  API Functions                                                                */
/*********************************************************************************/

/*********************************************************************************/
/*  Local Functions                                                              */
/*********************************************************************************/

#endif /* ABZ_CFG_H_ */